]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st-texture-cache: Use ClutterActor, not ClutterGroup
authorJasper St. Pierre <jstpierre@mecheye.net>
Tue, 14 Feb 2012 16:33:10 +0000 (11:33 -0500)
committerJasper St. Pierre <jstpierre@mecheye.net>
Thu, 16 Feb 2012 01:12:16 +0000 (20:12 -0500)
ClutterGroup is deprecated, and since ClutterActor is concrete, we
can use that now instead.

https://bugzilla.gnome.org/show_bug.cgi?id=670034

js/ui/panel.js
src/st/st-texture-cache.c
src/st/st-texture-cache.h

index 088719a447338bb4d9556684c49dfb1e29d56e25..c4cf09f626ade40b8619ad804e694382bbd4ee5e 100644 (file)
@@ -106,38 +106,47 @@ const AnimatedIcon = new Lang.Class({
     _init: function(name, size) {
         this.actor = new St.Bin({ visible: false });
         this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
-        this.actor.connect('notify::visible', Lang.bind(this, function() {
-            if (this.actor.visible) {
-                this._timeoutId = Mainloop.timeout_add(ANIMATED_ICON_UPDATE_TIMEOUT, Lang.bind(this, this._update));
-            } else {
-                if (this._timeoutId)
-                    Mainloop.source_remove(this._timeoutId);
-                this._timeoutId = 0;
-            }
-        }));
+        this.actor.connect('notify::visible', Lang.bind(this, this._onVisibleNotify));
 
         this._timeoutId = 0;
-        this._i = 0;
+        this._frame = 0;
         this._animations = St.TextureCache.get_default().load_sliced_image (global.datadir + '/theme/' + name, size, size);
         this.actor.set_child(this._animations);
     },
 
-    _update: function() {
-        this._animations.hide_all();
-        this._animations.show();
-        if (this._i && this._i < this._animations.get_n_children())
-            this._animations.get_nth_child(this._i++).show();
-        else {
-            this._i = 1;
-            if (this._animations.get_n_children())
-                this._animations.get_nth_child(0).show();
+    _disconnectTimeout: function() {
+        if (this._timeoutId > 0) {
+            Mainloop.source_remove(this._timeoutId);
+            this._timeoutId = 0;
         }
+    },
+
+    _onVisibleNotify: function() {
+        if (this.actor.visible)
+            this._timeoutId = Mainloop.timeout_add(ANIMATED_ICON_UPDATE_TIMEOUT, Lang.bind(this, this._update));
+        else
+            this._disconnectTimeout();
+    },
+
+    _showFrame: function(frame) {
+        let oldFrameActor = this._animations.get_child_at_index(this._frame);
+        if (oldFrameActor)
+            oldFrameActor.hide();
+
+        this._frame = (frame % this._animations.get_n_children());
+
+        let newFrameActor = this._animations.get_child_at_index(this._frame);
+        if (newFrameActor)
+            newFrameActor.show();
+    },
+
+    _update: function() {
+        this._showFrame(this._frame + 1);
         return true;
     },
 
     _onDestroy: function() {
-        if (this._timeoutId)
-            Mainloop.source_remove(this._timeoutId);
+        this._disconnectTimeout();
     }
 });
 
index 813c0fe4e1c1c75e4232152d0be3285095fff36b..0b5a920b8c0c9b25abcc390e97d80767a8d69958 100644 (file)
@@ -1162,7 +1162,7 @@ load_from_pixbuf (GdkPixbuf *pixbuf)
 typedef struct {
   gchar *path;
   gint   grid_width, grid_height;
-  ClutterGroup *group;
+  ClutterActor *actor;
 } AsyncImageData;
 
 static void
@@ -1170,7 +1170,7 @@ on_data_destroy (gpointer data)
 {
   AsyncImageData *d = (AsyncImageData *)data;
   g_free (d->path);
-  g_object_unref (d->group);
+  g_object_unref (d->actor);
   g_free (d);
 }
 
@@ -1190,7 +1190,7 @@ on_sliced_image_loaded (GObject *source_object,
     {
       ClutterActor *actor = load_from_pixbuf (GDK_PIXBUF (list->data));
       clutter_actor_hide (actor);
-      clutter_container_add_actor (CLUTTER_CONTAINER (data->group), actor);
+      clutter_actor_add_child (data->actor, actor);
     }
 }
 
@@ -1252,9 +1252,9 @@ load_sliced_image (GSimpleAsyncResult *result,
  * note that the dimensions of the image loaded from @path 
  * should be a multiple of the specified grid dimensions.
  *
- * Returns: (transfer none): A new #ClutterGroup
+ * Returns: (transfer none): A new #ClutterActor
  */
-ClutterGroup *
+ClutterActor *
 st_texture_cache_load_sliced_image (StTextureCache    *cache,
                                     const gchar       *path,
                                     gint               grid_width,
@@ -1262,14 +1262,14 @@ st_texture_cache_load_sliced_image (StTextureCache    *cache,
 {
   AsyncImageData *data;
   GSimpleAsyncResult *result;
-  ClutterGroup *group = CLUTTER_GROUP (clutter_group_new ());
+  ClutterActor *actor = clutter_actor_new ();
 
   data = g_new0 (AsyncImageData, 1);
   data->grid_width = grid_width;
   data->grid_height = grid_height;
   data->path = g_strdup (path);
-  data->group = group;
-  g_object_ref (G_OBJECT (group));
+  data->actor = actor;
+  g_object_ref (G_OBJECT (actor));
 
   result = g_simple_async_result_new (G_OBJECT (cache), on_sliced_image_loaded, data, st_texture_cache_load_sliced_image);
 
@@ -1278,7 +1278,7 @@ st_texture_cache_load_sliced_image (StTextureCache    *cache,
 
   g_object_unref (result);
 
-  return group;
+  return actor;
 }
 
 /**
index 5f1e7019326e7efe82b8070b683d86d8e249e600..7275703af69ab111660ba64d15e7362bc2b4e813 100644 (file)
@@ -68,7 +68,7 @@ GType st_texture_cache_get_type (void) G_GNUC_CONST;
 
 StTextureCache* st_texture_cache_get_default (void);
 
-ClutterGroup *
+ClutterActor *
 st_texture_cache_load_sliced_image (StTextureCache    *cache,
                                     const gchar       *path,
                                     gint               grid_width,